package demo.msa.rpc.common.util;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;

import java.util.Collection;
import java.util.Map;

/**
 * 集合工具类
 *
 * @author huangyong
 * @since 1.0.0
 */
public class CollectionUtil {

  /**
   * 判断 Collection 是否为空
   */
  public static boolean isEmpty(Collection<?> collection) {
    return CollectionUtils.isEmpty(collection);
  }

  /**
   * 判断 Collection 是否非空
   */
  public static boolean isNotEmpty(Collection<?> collection) {
    return !isEmpty(collection);
  }

  /**
   * 判断 Map 是否为空
   */
  public static boolean isEmpty(Map<?, ?> map) {
    return MapUtils.isEmpty(map);
  }

  /**
   * 判断 Map 是否非空
   */
  public static boolean isNotEmpty(Map<?, ?> map) {
    return !isEmpty(map);
  }
}